package arraylist;

import java.util.ArrayList;
import java.util.Scanner;

public class Test03 {
    public static void main(String[] args) {
        //创建扫描器
        Scanner sc = new Scanner(System.in);
        //创建Student集合
        ArrayList< Student> students= new ArrayList<Student>();
        //为集合遍历赋值
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入第"+(i+1)+"个学生的学号：");
            String id = sc.nextLine();
            System.out.println("请输入第"+(i+1)+"个学生的姓名：");
            String name = sc.nextLine();
            System.out.println("请输入第"+(i+1)+"个学生的年龄：");
            String age = sc.nextLine();
            Student s = new Student(id,name,age);
            students.add(s);
        }
        //遍历输出集合
        for (int i = 0; i < students.size(); i++) {
            System.out.println(students.get(i));
        }
    }
}
